/*
 * Ticketsaler.java
 *@author Bian Xiaoguang, Qian Wenshuo
 * Created on 2009-10-20, 20:21:33
 *
 * This view is used to show the main view.
 */

package view;
//import javax.swing.event.*;
//import java.awt.event.*;
/**
 *
 * @author Mark
 */
import javax.swing.*;

public class Ticketsaler extends javax.swing.JFrame  {

    /** Creates new form Ticketsaler */
    public Ticketsaler() {
        initComponents();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Regist = new javax.swing.JButton();
        CopyriteLabel = new javax.swing.JLabel();
        Login = new javax.swing.JButton();
        Tital = new javax.swing.JLabel();
        showAllTicketLabel = new javax.swing.JLabel();
        mgrLogin = new javax.swing.JButton();
        adminLogin = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        MassageTextArea = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        Regist.setText("Regist");
        Regist.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RegistActionPerformed(evt);
            }
        });

        CopyriteLabel.setText("copyrite CP3120-g404-2009");

        Login.setText("Login");
        Login.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LoginActionPerformed(evt);
            }
        });

        Tital.setFont(new java.awt.Font("Arial", 0, 18));
        Tital.setText("Welcome to airline ticketsaler!");

        showAllTicketLabel.setText("or show all the tickets we have!");
        showAllTicketLabel.setToolTipText("click to show all ticket.");
        showAllTicketLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        showAllTicketLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                showAllTicketLabelMouseClicked(evt);
            }
        });

        mgrLogin.setText("Mgr.Login");
        mgrLogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mgrLoginActionPerformed(evt);
            }
        });

        adminLogin.setText("Admin login");
        adminLogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                adminLoginActionPerformed(evt);
            }
        });

        MassageTextArea.setColumns(20);
        MassageTextArea.setRows(5);
        MassageTextArea.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                MassageTextAreaAncestorAdded(evt);
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });
        jScrollPane1.setViewportView(MassageTextArea);

        jLabel1.setText("Massages:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(CopyriteLabel)
                                    .addGroup(layout.createSequentialGroup()
                                        .addContainerGap()
                                        .addComponent(showAllTicketLabel)))
                                .addGap(15, 15, 15))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(Login)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(Regist))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(mgrLogin)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(adminLogin)))
                                .addGap(18, 18, 18)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 360, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(151, 151, 151)
                        .addComponent(Tital)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(59, Short.MAX_VALUE)
                .addComponent(Tital)
                .addGap(34, 34, 34)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(showAllTicketLabel)
                        .addGap(48, 48, 48)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(Regist, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Login, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(28, 28, 28)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(mgrLogin)
                            .addComponent(adminLogin))
                        .addGap(50, 50, 50)
                        .addComponent(CopyriteLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-600)/2, (screenSize.height-400)/2, 600, 400);
    }// </editor-fold>//GEN-END:initComponents

    private void RegistActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RegistActionPerformed
        new ucm.UCDisplayUserRegist();
        Ticketsaler.this.dispose();
}//GEN-LAST:event_RegistActionPerformed

    private void LoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoginActionPerformed
        new ucm.UCDispalyUserLogin();
        Ticketsaler.this.dispose();
    }//GEN-LAST:event_LoginActionPerformed

    private void mgrLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mgrLoginActionPerformed
            new ucm.UCDispalyMgrLogin();
            Ticketsaler.this.dispose();
    }//GEN-LAST:event_mgrLoginActionPerformed

    private void adminLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_adminLoginActionPerformed
                 new ucm.UCDisplayAdminLogin();
                 Ticketsaler.this.dispose();
    }//GEN-LAST:event_adminLoginActionPerformed

    private void showAllTicketLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_showAllTicketLabelMouseClicked
                          JOptionPane.showMessageDialog(new JFrame(),
                        "Londing the Database plaease wait for moment!",
                        "Success",
                        JOptionPane.INFORMATION_MESSAGE);
            new ucm.UCDispalyShowTicket();
Ticketsaler.this.dispose();
    }//GEN-LAST:event_showAllTicketLabelMouseClicked

    private void MassageTextAreaAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_MassageTextAreaAncestorAdded
       MassageTextArea.setText(getmassage(null));
    }//GEN-LAST:event_MassageTextAreaAncestorAdded



    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel CopyriteLabel;
    private javax.swing.JButton Login;
    private javax.swing.JTextArea MassageTextArea;
    private javax.swing.JButton Regist;
    private javax.swing.JLabel Tital;
    private javax.swing.JButton adminLogin;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton mgrLogin;
    private javax.swing.JLabel showAllTicketLabel;
    // End of variables declaration//GEN-END:variables
   public String getmassage(String news) {
   ucm.UCGetmassage mass = new ucm.UCGetmassage()  ;
   news = mass.getMassage(null);
   return news;
    }
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Ticketsaler().setVisible(true);
            }
        });
    }
}
